home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / demoCdef 120 ƒ / cdef3D source ƒ / Debug stuff / debugCDEF.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-31  |  1.9 KB  |  49 lines  |  [TEXT/KAHL]

  1. //----------------------------------------------------------------------------------
  2. // File        : debugCDEF.c
  3. // Date        : July 23, 1994
  4. // Author    : Jim Stout
  5. //            :
  6. // Purpose    : a dummy CDEF. I forget where I ran across this technique (an old 
  7. //            : MacTutor perhaps).  The goal here is to be able to test a code
  8. //            : definition with the Think C source debugger.
  9. //
  10. //            : To do this, you need the CDEF as 'inline' code, not as a code resource.
  11. //            : This is one way to do it.  Briefly, here is what to do:
  12. //
  13. //            : 1. Build this project as a CDEF with id=128 as file debug.rsrc.
  14. //
  15. //            : 2. Include the CDEF and a custom resource of type 'CJMP', id=128 in
  16. //            :    the .rsrc of your test project.  The 'CJMP' resouce should be a long. 
  17. //                        See testGeneric.r
  18. //
  19. //            : 3. Include your CDEF source code in a test project, but with an entry
  20. //            :    point of CDEFmain() instead of main().  
  21. //                        See genericCDEF.c in project testGeneric π.
  22. //
  23. //            : 4. In your test source, where main() is found plug the address of 
  24. //            :    CDEFmain into the 'CJMP' resource.  
  25. //                        See testGeneric.c in project testGeneric π.
  26. //
  27. //            : 5. Use 128 as the CDEF id in your resource templates. 
  28. //                        See testGeneric.r in project testGeneric π.
  29. //
  30. //            : If you have done things correctly, when the Control Manager tries to
  31. //            : call CDEF 128, it gets this code instead, which recovers the address
  32. //            : of CDEFmain and calls it.  The Think Debugger can then be used to
  33. //            : step through the source of your CDEF.  When it is working, simply
  34. //            : build your CDEF as a code resource.
  35. //                        See genericCDEF π.
  36. //----------------------------------------------------------------------------------
  37. #include "debugCDEF.h"
  38.  
  39. pascal long main (short varCode, ControlHandle theControl, short message, long param)
  40. {
  41.     CJMPhdl    h;
  42.     long    result=0;
  43.     
  44.     h = (CJMPhdl)GetResource('CJMP',128);
  45.     if(h != nil) {
  46.         result = CallPascalL(varCode,theControl,message,param,(**h).cdefPtr);
  47.     }
  48.     return result;
  49. }